package cn.cyh.web;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Charlie on 2017/11/17.
 */
@Controller
public class HelloController {

    @ResponseBody
    @GetMapping(value = "/hello")
    public String hello(){
        return "Hello Spring Boot";
    }

    @RequestMapping("/index")
    public String index(ModelMap modelMap){
        modelMap.addAttribute("host", "哎哟，不错哟！");
        modelMap.addAttribute("name", "Charlie");
        return "index";
    }

    @RequestMapping(value = "/exception")
    public String exception() throws Exception{
        throw new  Exception("这是一个test异常！");
    }

}
